/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.me.mobisegua.adapter;


/**
 *
 * @author Zé Carlos
 */
public class DBBuilder
{

    MobiSegUAAdapter db;

    public DBBuilder(MobiSegUAAdapter _db)
    {
        this.db = _db;
    }

    public void fillDB()
    {
        insertArea("Zona Norte", "40.635027", "-8.657881");
        insertArea("Area 2");
        insertArea("Area 3");
        insertArea("Area 4");
        insertArea("Area 5");
        insertDept("ESSUA", 1,"40.634848","-8.657607");
        insertDept("Dept. Línguas", 1,"40.635239","-8.658112");
        insertDept("IT", 2,"40.634184","-8.660129");
        insertDept("IEETA", 2,"40.63315","-8.660231");
        insertDept("DETI", 2,"40.632918" ,"-8.659517");
        insertDept("Dept. Biologia", 2,"40.6337","-8.659571");
        insertDept("Dept. Ambiente", 2,"40.632942","-8.659346");
        insertDept("CIFOP", 2,"40.632177","-8.658734");
        insertDept("Exterior", 2,null,null);
        insertTipoObjecto("Porta");
        insertTipoObjecto("Parede");
        insertTipoObjecto("Janela");
        insertTipoObjecto("Lâmpada");
        insertTipoObjecto("Planta");
        insertTipoObjecto("Outro");
        insertTipoOcorrencia("Arrombada", 1);
        insertTipoOcorrencia("Riscada", 1);
        insertTipoOcorrencia("Riscada", 2);
        insertTipoOcorrencia("Pintada", 2);
        insertTipoOcorrencia("Partida", 3);
        insertTipoOcorrencia("Fundida", 4);
        insertTipoOcorrencia("Outro", 6);
    }


    private void insertArea(String name)
    {
        db.open();
        db.insertArea(name);
        db.close();
    }
    
    private void insertArea(String name, String Latitude, String Longitude)
    {
        db.open();
        db.insertArea(name, Latitude, Longitude);
        db.close();
    }

    private void insertDept(String name, int RefIDArea, String Latitude, String Longitude)
    {
        db.open();
        db.insertDept(name, RefIDArea, Latitude, Longitude);
        db.close();
    }

    private void insertTipoObjecto(String name)
    {
        db.open();
        db.insertTipoObjecto(name);
        db.close();
    }

    private void insertTipoOcorrencia(String name, int RefIDTipoObjecto)
    {
        db.open();
        db.insertTipoOcorrencia(name, RefIDTipoObjecto);
        db.close();
    }

}
